﻿@using KPIS.GERP.Models.SYS.Resources
@model KPIS.GERP.Models.FIM.MasBankBranch

@{
    Layout = "~/Views/Shared/_EmptyLayout.cshtml";
    ViewBag.Title = "ธนาคาร";
    ViewBag.Descr = "ข้อมูลธนาคาร";

}

<div>
    @using (Html.BeginForm("EditBankBranch", "MasBank", FormMethod.Post
        , new { @class = "form-horizontal" }))
    {
        @Html.AntiForgeryToken()

        <div class="block-button-menu-above">
            <a id="cmdClose" href="#" class="btn btn-small button-standard-width btn-danger" data-dismiss="modal" onclick="closeModal()">ปิด</a>
            @Html.ButtonSubmit()
        </div>
    
        <div class="alert-error">@Html.ValidationSummary()</div>
        @Html.Partial("_EditorFormBranch")

    }
</div>

@section scripts
{
    <script>
        $(function () {
            $("form").submit(function (e) {
                var currentForm = this;
                bootbox.confirm(function (result) {
                    var _result = result;
                    if (result) {
                        $.ajax({
                            url: currentForm.action,
                            type: currentForm.method,
                            data: $(currentForm).serialize(),
                            success: function (result) {
                                if (result.result) {
                                    bootbox.alert(result.message, "ตกลง", function () {
                                        closeModal();
                                    });
                                }
                                else {
                                    bootbox.alert(result.message, "ตกลง", function () {
                                        bootbox.hideAll();
                                    });
                                }
                            }
                        });

                        return false;
                    }
                });

                return false;
            });

            $(".chzn-select").chosen({ width: '220px' });
        });

        function closeModal() {
            var $jParent = window.parent.jQuery.noConflict();
            $jParent('#modal').modal('hide');
        }

    </script>
}


